package com.zys.exercise;
//随机生成验证码
import java.util.Random;

public class text3 {
    public static void main(String[] args) {
        Random r = new Random();
        char[] alpha = new char[52];
        for (int i = 0; i < alpha.length; i++) {
            if(i<26){
                alpha[i]=(char)(97+i);
            }else{
                alpha[i]=(char)(65+i-26);
            }
        }
//        for (int i = 0; i < alpha.length; i++) {
//            System.out.print(alpha[i]);
//        }
//        System.out.println(alpha[r.nextInt(alpha.length)]);
//输出的是整数，所以后面的输出有问题
//        System.out.println(1+'a');
//通过加字符串来解决
//实现随机位数验证码
        for(int i=0;i<r.nextInt(4,7);i++){
            System.out.print(alpha[r.nextInt(alpha.length)]);
        }
        System.out.println();
        System.out.println(""+alpha[r.nextInt(alpha.length)]+r.nextInt(0,10)+r.nextInt(0,10)+alpha[r.nextInt(alpha.length)]);
    }
}
